<?php 

namespace app\seller\event;

use app\common\model\ShopCategory as ShopCategoryModel;
use app\common\utils\JsonService;

class ShopCategoryEvent{

    /*
    * 分类列表
    */
    public static function categoryList($where=[]){

        $category = ShopCategoryModel::getTree(0,$where);
        return $category;
    }


    /*
    * 新增分类
    */
    public static function createCategory($data){

        try {
            ShopCategoryModel::create($data);
        } catch (\Exception $ex) {
            return JsonService::error($ex->getMessage());
        }
        return JsonService::success();
    }

    /*
    * 更新分类
    */
    public static function updateCategory($data){

        try {
            ShopCategoryModel::updateOne($data, ['id' => $data['id']]);
        } catch (\Exception $ex) {
            return JsonService::error($ex->getMessage());
        }
        return JsonService::success();
    }


}

